<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/2/27
 * Time: 20:18
 */

namespace App\Utils;

use Monolog\Handler\FirePHPHandler;
use Monolog\Handler\StreamHandler;
use Monolog\Logger;

class MyLogger
{

    private static $loggers = array();

    public static function log(string $message, array $dataArray = [], string $type = 'my_log')
    {
        if (!isset(self::$loggers[$type])) {
            $logger = new Logger($type);
            $logger->pushHandler(new StreamHandler(storage_path($type . '.log'), Logger::INFO));
            $logger->pushHandler(new FirePHPHandler());
            self::$loggers[$type] = $logger;
        }
        $log = self::$loggers[$type];
        return $log->info($message, $dataArray);
    }

}